package com.gujiangbo.chapter02;

import sun.misc.Launcher;
import sun.security.ec.CurveDB;

import java.net.URL;
import java.security.Provider;
import java.util.Arrays;

/**
 * @Author: gujiangbo.co
 * @Contact: 646832012@qq.com
 * @Date: 2022/3/23 16:59
 * @Version: 1.0
 * @Description: 类加载器
 */
public class JavaClassLoader02 {

    public static void main(String[] args) {
        System.out.println("========启动类加载器============");
        URL[] urLs = Launcher.getBootstrapClassPath().getURLs();
        Arrays.stream(urLs).forEach(System.out::println);
        // 从上面结果类选择一个对象，查看类加载器
        ClassLoader classLoader = Provider.class.getClassLoader();
        System.out.println(classLoader);

        System.out.println("========扩展类加载器============");
        String dirs = System.getProperty("java.ext.dirs");
        Arrays.stream(dirs.split(";")).forEach(System.out::println);
        // 从ext目录下选择一个类查看类加载器
        ClassLoader classLoader1 = CurveDB.class.getClassLoader();
        System.out.println(classLoader1);
    }
}
